import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { TDesignResolver } from '@tdesign-vue-next/auto-import-resolver'
import path from 'path'

// https://vite.dev/config/
export default defineConfig(({ mode }) => {
    return {
        base: loadEnv(mode, process.cwd()).VITE_BASE_URL,
        server: {
            host: true
        },
        resolve: {
            alias: {
                '@': path.resolve(__dirname, 'src')
            }
        },
        plugins: [
            vue(),
            AutoImport({
                resolvers: [
                    TDesignResolver({
                        library: 'vue-next',
                    })
                ],
            }),
            Components({
                resolvers: [
                    TDesignResolver({
                        library: 'vue-next',
                    })
                ],
            }),
        ],
    }
})
